<?php
/***************************************************************
*  Copyright notice
*  (c) 2009, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
//exit();
//exit();

//
require(dirname(dirname(__FILE__)) . '/includes/application_top.php');

//
include_once(CONFIG_PATH . CONFIG_DIR_INCLUDES . 'functions/thumb.function.php');
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.directory.class.php');

//
$dir = CONFIG_PATH . CONFIG_DIR_PRODUCTS_IMAGES . 'origins/200904/';
$dObj = new CoreDirectory($dir);
$dObj->parse();
$dir = $dObj->_dir;
$files = $dObj->getFiles();
if( is_array($files) ) {
	foreach($files as $k => $v) {
		$file = $v['file'];
		if( substr($file, -5) == '.jpeg' || substr($file, -4) == '.jpg' || substr($file, -4) == '.bmp' || substr($file, -4) == '.gif' || substr($file, -4) == '.png' ) {
			$products_image = $file;
			$products_image_save_file = $dir . $file;
			
			//thumbs
			$thumb_file = CONFIG_PATH . 'images/products/thumbs/' . $products_image;
			$thumb_width = CONST_IMAGE_RESIZE_WIDTH;
			$thumb_height = CONST_IMAGE_RESIZE_HEIGHT;
			func_thumb_generate_thumb($products_image_save_file, $thumb_file, $thumb_width, $thumb_height);
		}
	}
}
//
echo 'OK';
//
?>